package com.learn.controller;

import com.learn.controller.dto.AddNoticeReq;
import com.learn.controller.dto.NoticeType;
import com.learn.feign_service.DeptFeignService;
import com.learn.feign_service.NoticeFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/feign")
public class FeignConsumerController {
    @Autowired
    private DeptFeignService deptFeignService;
    
    @Autowired
    private NoticeFeignService noticeFeignService;
    
    @PostMapping("/addDept")
    public String addDept(String name) {
        return deptFeignService.addDept(name);
    }
    
    @PostMapping("/findOneDept")
    public String findOneDept(Integer id) {
        return deptFeignService.findOneDept(id);
    }
    
    @PostMapping("/findAllDept")
    public String findAllDept() {
        return deptFeignService.findAllDept();
    }
    
    @PostMapping("/addNotice")
    public String addNotice(@RequestBody AddNoticeReq req) {
        return noticeFeignService.addDept(req);
    }
    
    @PostMapping("/listNoticeByType")
    public String listNoticeByType(NoticeType noticeType) {
        return noticeFeignService.findOneDept(noticeType);
    }
    
    @PostMapping("/findAllNotice")
    public String findAllNotice() {
        return noticeFeignService.findAllNotice();
    }
}
